﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.ComponentModel;

namespace Liquid.Windows.Commands.ToolStrips {
	public class ToolStripMenuItemCommandBinding : ToolStripItemCommandBinding {
		public ToolStripMenuItemCommandBinding(ToolStripMenuItem item)
			: base(item) {
			item.Click += new EventHandler(item_Click);
		}

		void item_Click(object sender, EventArgs e) {
			var ce = e as CancelEventArgs
				?? new CancelEventArgs(false);
			Command.Activate(ce);
		}

		public new ToolStripMenuItem Item {
			get { return (ToolStripMenuItem)base.Item; }
			protected set { base.Item = value; }
		}

		protected internal override void OnCheckedStateChanged(EventArgs e) {
			Item.CheckState = Command.CheckedState;
			base.OnCheckedStateChanged(e);
		}
	}
}
